﻿/*
 * Copyright 2014 Francois Karman
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;

namespace Quartz.Ext
{
    /// <summary>
    /// Provides details about a property that is part of a <see cref="JobDataMap"/> of a job instance.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class PropertyAttribute : Attribute
    {
        /// <summary>
        /// The internal name of the property.
        /// </summary>
        private readonly string name;

        /// <summary>
        /// The type of the property.
        /// </summary>
        private readonly string type;

        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyAttribute"/> class.
        /// </summary>
        /// <param name="name">The internal name of the property.</param>
        /// <param name="type">The type of the property.</param>
        public PropertyAttribute(string name, string type)
        {
            this.name = name;
            this.type = type;
            this.DisplayName = name;
        }

        /// <summary>
        /// Gets the internal name of the property.
        /// </summary>
        public string Name { get { return this.name; } }

        /// <summary>
        /// Gets teh type of the property.
        /// </summary>
        public string Type { get { return this.type; } }

        /// <summary>
        /// Gets or sets the display name of the property; could be <c>null</c>.
        /// </summary>
        public string DisplayName { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the property is required.
        /// </summary>
        /// <value>
        /// <c>false</c> by default.
        /// </value>
        public bool Required { get; set; }

        /// <summary>
        /// Gets or sets a description for the property; could be <c>null</c>.
        /// </summary>
        public string Description { get; set; }
    }
}
